package com.learning.mybatis.plugin.application.plugin.readingwritingseparation;

/**
 * ClassName: DynamicDataSourceHolder
 * Description:
 * Date: 2019/3/29 16:14 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
public final class DynamicDataSourceHolder {
    private static final ThreadLocal<DynamicDataSourceGlobal> HOLDER = new ThreadLocal<>();


    private DynamicDataSourceHolder() {
    }

    public static void putDataSource(DynamicDataSourceGlobal dataSource) {
        HOLDER.set(dataSource);
    }

    public static DynamicDataSourceGlobal getDataSource() {
        return HOLDER.get();
    }

    public static void clearDataSource() {
        HOLDER.remove();
    }
}
